package com.mmall.concurrency.example.singleton;

import com.mmall.concurrency.annotions.Recommends;
import com.mmall.concurrency.annotions.ThreadSafes;


/**
 * <p>Descriptions...
 *
 * @author Diamon.Cheng
 * @date 2019/12/5.
 */
@ThreadSafes
@Recommends
public class SingletonExample_7 {


    private  SingletonExample_7(){}
    
    public static  SingletonExample_7 getInstance(){
        
        return Singleton.INSTANCE.getInstance();
    }
    
    private enum Singleton {
        INSTANCE;
        
        private SingletonExample_7 singleton;
        
        // JVM保证这个方法绝对只调用一次
        Singleton() {
            singleton = new SingletonExample_7();
        }
        
        public SingletonExample_7 getInstance() {
            return singleton;
        }
    }
    
    
}
